<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<jsp:useBean id="Candidate"
	class="com.ignou.mca.beans.CandidatesFormBean" scope="request" />
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="com.ignou.mca.datasource.DataBaseUtilities"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="com.ignou.mca.beans.UserVO"%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Add Candidates</title>
<link rel="stylesheet" href="theme/Master.css" type="text/css">
<script language="javascript">
	function candidateFocus() {
		document.fm.candidateName.focus();
	}
	
	function checkMandatoryFields() {
		var cname, add1, add2, city, state, country, ph;
		cname = document.fm.candidateName.value;
		add1 = document.fm.address1.value;
		add2 = document.fm.address2.value;
		city = document.fm.city.value;
		state = document.fm.state.value;
		country = document.fm.country.value;
		ph = document.fm.phno.value;

		if (cname.length < 1) {
			alert("You must enter candidate name");
			document.fm.candidateName.focus();
			return false;
		} else if (add1.length < 1) {
			alert("You must enter Address1");
			document.fm.address1.focus();
			return false;
		} else if (add2.length < 1) {
			alert("You must enter Address2");
			document.fm.address2.focus();
			return false;
		} else if (city.length < 1) {
			alert("You must enter City");
			document.fm.city.focus();
			return false;
		} else if (state.length < 1) {
			alert("You must enter State");
			document.fm.state.focus();
			return false;
		} else if (country.length < 1) {
			alert("You must enter Country");
			document.fm.country.focus();
			return false;
		} else if (ph.length < 1) {
			alert("You must enter Phone Number");
			document.fm.phno.focus();
			return false;
		}

		return true;
	}
</script>



</head>
<body onload="return candidateFocus()">
<%
	UserVO userVoObj = (UserVO) session.getAttribute("UserVO");
	if (userVoObj == null) {
		response.sendRedirect(request.getContextPath() + "/Home.htm");
	}
%>
<table width="100%" border="0" cellpadding="0" cellspacing="0"
	bgcolor="#FFFFFF">
	<tr>
		<td height="21" bgcolor="#495e83"></td>
		<td height="21" bgcolor="#495e83"></td>
	</tr>
	<tr>
		<td height="119" align="left" valign="middle" bgcolor="#FFFFFF">
		<img alt="" src="././images/company_logo.JPG" width="304" height="53">
		</td>
		<td align="right" width="287"><img alt=""
			src="images/header_graphic.jpg" width="287" height="119"></td>
	</tr>
	<tr>
		<td height="45" width="100%" valign="middle" bgcolor="#495e83">
		&nbsp; &nbsp; &nbsp; <a href="AdminMenu.jsp" class="links" target="">Main Menu</a>
		&nbsp; &nbsp; &nbsp;<a href="Logout.jsp" class="links" target="">Logout</a>
		</td>

		<td bgcolor="#495e83"></td>
	</tr>
	<tr>
		<td height="1"><img alt="" src="images/spacer.gif" width="1"
			height="1"></td>
		<td height="1"><img alt="" src="images/spacer.gif" width="1"
			height="1"></td>
	</tr>
	<tr background="images/links_bot_fill.gif">
		<td height="30">&nbsp;</td>
		<td>&nbsp;</td>
	</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="5"
	align="center">
	<tr>
		<td bgcolor="#FFFFFF" width="20"><img alt=""
			src="images/spacer.gif" width="20" height="10"></td>
		<td bgcolor="#FFFFFF" align="left" valign="top" class="text"
			height="309" width="99%"><br>
		<!-- #BeginEditable "content" -->
		<p class="title" align="center">Add Candidates</p>
		<br>
		<FORM name="fm" action="AddCandidates" method="post"
			onsubmit="return checkMandatoryFields()">
		<DIV align="center" style=""><B>*All fields are mandatory</B> <br>
		<TABLE border="0" width="80" height="10" cellspacing="0"
			cellpadding="10">
			<TBODY>
				<TR>
					<TD nowrap width="30%">Candidate Name:</TD>
					<TD width="36"></TD>
					<TD width="92"><INPUT type="text" name="candidateName"
						value='<%=Candidate.getCandidateName()%>' size="20"></TD>
				</TR>
				<TR>
					<TD nowrap width="30%">Address 1:</TD>
					<TD width="36"></TD>
					<TD width="92"><INPUT type="text" name="address1"
						value='<%=Candidate.getAddress1()%>' size="20"></TD>

					<TD nowrap width="30%">Address 2:</TD>
					<TD width="36"></TD>
					<TD width="92"><INPUT type="text" name="address2"
						value="<%=Candidate.getEmail()%>" size="20"></TD>
				</TR>
				<TR>
					<TD nowrap width="30%">City:</TD>
					<TD width="36"></TD>
					<TD width="92"><INPUT type="text" name="city"
						value="<%=Candidate.getCity()%>" size="20"></TD>

					<TD nowrap width="30%">State:</TD>
					<TD width="36"></TD>
					<TD width="92"><INPUT type="text" name="state"
						value="<%=Candidate.getState()%>" size="20"></TD>
				</TR>
				<TR>
					<TD nowrap width="30%">Country:</TD>
					<TD width="36"></TD>
					<TD width="92"><INPUT type="text" name="country"
						value="<%=Candidate.getCountry()%>" size="20"></TD>
				</TR>
				<TR>
					<TD nowrap width="30%">Phone Number:</TD>
					<TD width="36"></TD>
					<TD width="92"><INPUT type="text" name="phno"
						value="<%=Candidate.getPhno()%>" size="20"></TD>

					<TD nowrap width="30%">Email:</TD>
					<TD width="36"></TD>
					<TD width="92"><INPUT type="text" name="email"
						value="<%=Candidate.getEmail()%>" size="20"></TD>
				</TR>
				<TR>
					<TD nowrap width="30%">Position:</TD>
					<TD width="36"></TD>
					<TD width="92">
					<%
						DataBaseUtilities dbu = new DataBaseUtilities();
						ResultSet rs = dbu.viewAllPositions();
						out.println("<select name='position'>");
						while (rs.next()) {
							out.println("<option value=" + rs.getInt(1) + ">"
									+ rs.getString(2) + " </option>");
						}
						out.println("</select>");
					%>
					</TD>

					<TD nowrap width="30%">Party:</TD>
					<TD width="36"></TD>
					<TD width="92">
					<%
						ResultSet rs1 = dbu.viewAllParties();
						out.println("<select name='party'>");
						while (rs1.next()) {
							out.println("<option value=" + rs1.getInt(1) + ">"
									+ rs1.getString(2) + " </option>");
						}
						out.println("</select>");
					%>
					</TD>
					</TR>
					<TR>
					<TD nowrap width="30%">Picture URL:</TD>
					<TD width="36"></TD>
					<TD width="92">
						<INPUT type="text" name="personPictureURL"
						value="<%=Candidate.getPicURL()%>" size="20">
					</TD>
					
				</TR>
			</TBODY>
		</TABLE>
		<BR>
		<BR>
		</DIV>
		<DIV align="center"><INPUT type="reset" value="Clear"> <INPUT
			type="submit" name="Submit" value="Submit"></DIV>
		</FORM>
		<CENTER><jsp:useBean id="Message"
			class="com.ignou.mca.beans.Message" scope="session">
		</jsp:useBean> <jsp:getProperty name="Message" property="message" /> <br>



	</tr>
	<tr>
		<td bgcolor="#495e83" width="20">&nbsp;</td>
		<td height="35" align="center" valign="middle" bgcolor="#495e83"
			class="footer">Copyright &copy; 2011 All Rights Reserved.
		Designed by Pradeepthi S</td>
		<td bgcolor="#495e83" width="20">&nbsp;</td>

	</tr>

</table>
</body>
</html>